﻿using Com.JunCaiSoft.Permission.Entity;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Com.JunCaiSoft.Permission.EntityMap
{
    public class PositionMap : IEntityTypeConfiguration<Position>
    {
        public void Configure(EntityTypeBuilder<Position> builder)
        {
            builder.ToTable("Position");

            builder.HasKey(k => k.Id);

            builder.HasOne(h => h.User)
                .WithMany(w => w.Positions)
                .HasForeignKey(k => k.UserId);

            builder.HasOne(h => h.Role)
                .WithMany(w => w.Positions)
                .HasForeignKey(k => k.RoleId);
        }
    }
}
